package com.neusoft.hifly.dynamicds.multi.datasource.domain;

import java.io.Serializable;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

/**
 * Title: 分布式动态数据源路由
 * <p>
 * Description: 数据源对象
 * <p>
 * Copyright: 2018
 * <p>
 * Company: 东软汉枫
 *
 * @author lh_neu
 * @version 1.0.0
 */
public class DatasourceRouterObj implements Serializable {
	public static final String REDIS_KEY = "app:datasource";

	private static final long serialVersionUID = 6207270322942843046L;

	// 逻辑ID
	private String logicId;
	// 名称
	private String name;
	// 数据库实例名称
	private String dbName;
	// 数据库类型（ORACLE/MYSQL/SQLSERVER）
	private String dbType;
	// 数据库字符集（GBK/UTF-8）
	private String dbCharacter;
	// 数据库地址（IP/双机地址）
	private String dbUrl;
	// 数据库端口号（1521/3306）
	private String dbPort;
	// 数据库用户名称
	private String dbUser;
	// 数据库用户密码
	private String dbPassword;

	/**
	 * 得到对象的哈希值
	 *
	 * @return int 对象的哈希值
	 */
	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(this.getLogicId()).toHashCode();
	}

	/**
	 * 比较两个对象是否相等
	 *
	 * @param other
	 *            要比较的对象
	 * @return boolean 相同返回true，否则返回flase
	 */
	@Override
	public boolean equals(final Object other) {
		if (!(other instanceof DatasourceRouterObj)) {
			return false;
		}
		final DatasourceRouterObj castOther = (DatasourceRouterObj) other;
		return new EqualsBuilder().append(this.getLogicId(), castOther.getLogicId()).isEquals();
	}

	/**
	 * 返回对象的字符串值
	 *
	 * @return String 表示用户对象的字符串值
	 */
	@Override
	public String toString() {
		return new ToStringBuilder(this).append("数据源", this.getName()).toString();
	}

	public String getLogicId() {
		return logicId;
	}

	public void setLogicId(String logicId) {
		this.logicId = logicId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDbName() {
		return dbName;
	}

	public void setDbName(String dbName) {
		this.dbName = dbName;
	}

	public String getDbType() {
		return dbType;
	}

	public void setDbType(String dbType) {
		this.dbType = dbType;
	}

	public String getDbCharacter() {
		return dbCharacter;
	}

	public void setDbCharacter(String dbCharacter) {
		this.dbCharacter = dbCharacter;
	}

	public String getDbUrl() {
		return dbUrl;
	}

	public void setDbUrl(String dbUrl) {
		this.dbUrl = dbUrl;
	}

	public String getDbPort() {
		return dbPort;
	}

	public void setDbPort(String dbPort) {
		this.dbPort = dbPort;
	}

	public String getDbUser() {
		return dbUser;
	}

	public void setDbUser(String dbUser) {
		this.dbUser = dbUser;
	}

	public String getDbPassword() {
		return dbPassword;
	}

	public void setDbPassword(String dbPassword) {
		this.dbPassword = dbPassword;
	}

}